package com.hao.study.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hao.study.entity.Tag;
import com.hao.study.mapper.TagMapper;
import com.hao.study.service.TagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: author
 * @description:
 * @date: 2024/6/11 17:51
 * @version: 1.0
 */
@Service
public class TagServiceImpl implements TagService {
    @Autowired
    TagMapper tagMapper;
    @Override
    public PageInfo<Tag> getTagList(Integer pageNum,Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Tag> tags=tagMapper.selectList(new QueryWrapper<>());
        return PageInfo.of(tags);
    }

    @Override
    public void createTag(Tag tag) {
        System.out.println(tag);
        tag.setCreateTime(String.valueOf(System.currentTimeMillis()));
        tagMapper.insert(tag);
    }

    @Override
    public void deleteTag(String id) {
        tagMapper.deleteById(id);
    }

    @Override
    public void updateTag(Tag tag) {
        tagMapper.updateById(tag);
    }
}
